﻿#include <iostream>
#include "threadpool.h"
using namespace std;

int calc(int x, int y)
{
    int res = x + y;
    this_thread::sleep_for(chrono::seconds(2));
    return res;
}
int main()
{
    CThreadPool pool(4);
    vector<future<int>> results;

    for (int i = 0; i < 10; ++i) {
        results.emplace_back(pool.addTask(calc, i, i * 2));
    }

    for (auto&& res : results) {
        cout << "results: " << res.get() << endl;
    }
    return 0;
}
